/*
 * Zhiyuanxinxi.java
 *
 * Created on __DATE__, __TIME__
 */

package WindowsModule;

import javax.swing.WindowConstants;

import Client.ClientListener;
import Client.MsgEvent;
import Tools.IMG;
import Tools.ToCenter;
import Tools.Units;
import Windows.MainWindows;
import Windows.PicPanel;
import Windows.ShowWindows.ShowWindow;
import XML.XML;
import XML.XMLNode;

/**
 * 
 * @author __USER__
 */
public class Zhiyuanxinxi extends javax.swing.JFrame implements ClientListener {
	// End of variables declaration//GEN-END:variables
	public static void main(String[] args) {
		new Zhiyuanxinxi().setVisible(true);
	}
	private final PicPanel pp = new PicPanel(IMG.DOWNLOADBG);

	private XMLNode xn = null;

	// GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JLabel jLabel1;

	private javax.swing.JLabel jLabel10;

	private javax.swing.JLabel jLabel11;
	private javax.swing.JLabel jLabel12;
	private javax.swing.JLabel jLabel13;
	private javax.swing.JLabel jLabel14;
	private javax.swing.JLabel jLabel15;
	private javax.swing.JLabel jLabel18;
	private javax.swing.JLabel jLabel19;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel20;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JLabel jLabel6;
	private javax.swing.JLabel jLabel7;
	private javax.swing.JLabel jLabel8;
	private javax.swing.JLabel jLabel9;
	private javax.swing.JPanel jPanel;
	/** Creates new form Zhiyuanxinxi */
	public Zhiyuanxinxi() {

		this.setContentPane(pp);

		jPanel = new PicPanel(null, IMG.LOGIN_BG2);

		initComponents();
		MainWindows.getInstance().client.addClientListenser(this);

		jLabel19.setBounds(0, 8, 1, 1);

		this.addWindowListener(ShowWindow.getWindowListener());

	}
	public void display(XMLNode xmln) {
		if (xmln == null || xmln.get("md5") == null) {
			return;
		}
		this.xn = xmln.clone();

		this.setTitle("资源详细信息");
		ToCenter.ToCenter(this);

		xn.FLAG = "resInfo";
		MainWindows.getInstance().client.send(xn);

		this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	// GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jLabel1 = new javax.swing.JLabel();
		jLabel2 = new javax.swing.JLabel();
		jLabel3 = new javax.swing.JLabel();
		jLabel4 = new javax.swing.JLabel();
		jLabel5 = new javax.swing.JLabel();
		jLabel6 = new javax.swing.JLabel();
		jLabel7 = new javax.swing.JLabel();
		jLabel8 = new javax.swing.JLabel();
		jLabel9 = new javax.swing.JLabel();
		jLabel10 = new javax.swing.JLabel();
		jLabel11 = new javax.swing.JLabel();
		jLabel12 = new javax.swing.JLabel();
		jLabel13 = new javax.swing.JLabel();
		jLabel14 = new javax.swing.JLabel();
		jLabel15 = new javax.swing.JLabel();
		jLabel18 = new javax.swing.JLabel();
		jLabel19 = new javax.swing.JLabel();
		jLabel20 = new javax.swing.JLabel();

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

		jLabel1.setFont(new java.awt.Font("YouYuan", 1, 15));
		jLabel1.setText("\u8d44\u6e90\u4fe1\u606f");

		jLabel2.setText("\u8d44\u6e90\u540d\u79f0\uff1a");

		jLabel3.setText("\u8d44\u6e90\u5927\u5c0f\uff1a");

		jLabel4.setText("\u66f4\u65b0\u65e5\u671f\uff1a");

		jLabel5.setText("\u7c7b  \u578b\uff1a");

		jLabel6.setText("\u8d44\u6e90\u6570\u91cf\uff1a");

		jLabel7.setText("\u6587\u4ef6MD5\uff1a");

		jLabel8.setText("jLabel8");

		jLabel9.setText("jLabel9");

		jLabel10.setText("jLabel10");

		jLabel11.setText("jLabel11");

		jLabel12.setText("jLabel12");

		jLabel13.setText("jLabel13");

		jLabel14.setText("\u8bc4\u8bba\u6570\u91cf\uff1a");

		jLabel15.setText("\u8d44\u6e90\u4ef7\u503c\uff1a");

		jLabel18.setText("jLabel18");

		jLabel19.setBackground(new java.awt.Color(153, 204, 255));
		jLabel19.setAutoscrolls(true);

		javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(jPanel);
		jPanel.setLayout(jPanelLayout);
		jPanelLayout.setHorizontalGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanelLayout.createSequentialGroup().addContainerGap().addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel2).addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jLabel5).addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel4).addComponent(jLabel6).addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING))).addComponent(jLabel3)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE).addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanelLayout.createSequentialGroup().addComponent(jLabel15).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel20)).addGroup(jPanelLayout.createSequentialGroup().addComponent(jLabel14).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18).addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))).addContainerGap(110, Short.MAX_VALUE)));
		jPanelLayout.setVerticalGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanelLayout
						.createSequentialGroup()
						.addGroup(
								jPanelLayout
										.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
										.addGroup(jPanelLayout.createSequentialGroup().addContainerGap().addComponent(jLabel20).addGap(95, 95, 95).addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
										.addGroup(
												jPanelLayout
														.createSequentialGroup()
														.addGap(20, 20, 20)
														.addGroup(
																jPanelLayout
																		.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
																		.addGroup(jPanelLayout.createSequentialGroup().addComponent(jLabel8).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel9).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel10).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel11).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel18).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel13))
																		.addGroup(
																				jPanelLayout.createSequentialGroup().addComponent(jLabel2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel3).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel4).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel5).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel6).addComponent(jLabel14).addComponent(jLabel12)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																						.addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel7).addComponent(jLabel15)))))).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel1).addComponent(jPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addContainerGap()));
		layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel1).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addContainerGap()));

		pack();
	}// </editor-fold>
		// GEN-END:initComponents

	@Override
	public void onCloseEvent(Client.CloseEvent cce) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onMsgEvent(MsgEvent ce) {
		if (ce.getCmd().FLAG.equals("resInfo")) {
			XML cmd = ce.getCmd();
			String title = cmd.get("title");
			jLabel8.setText(title.substring(0, title.length() > 25 ? 25 : title.length()));
			jLabel9.setText(Units.byteCondense(Long.valueOf(cmd.get("length"))));// 资源大小
			jLabel10.setText(cmd.get("time"));
			jLabel11.setText(cmd.get("type"));
			jLabel13.setText(cmd.get("md5"));
			jLabel12.setText(cmd.get("pipSum"));
			jLabel18.setText(cmd.get("resNum"));

			System.out.println("resJiazi  " + cmd.get("resJiazi"));

			ShowWindow.DisplayWindow(this, 1);
		}
	}
}